<template>
	<view>
		<view class="tui-addr-box">
			<form :report-submit="true" style="font-family:PingFang SC;">
				<view class="tui-line-cell">
					<view class="tui-title">提货人</view>
					<input placeholder-class="tui-phcolor" v-model="addseedata.name" class="tui-input" name="name"
						placeholder="请填写提货人" maxlength="15" type="text" />
				</view>
				<view class="tui-line-cell">
					<view class="tui-title">手机号码</view>
					<input placeholder-class="tui-phcolor" v-model="addseedata.phone" class="tui-input" name="mobile"
						placeholder="请填写手机号码" maxlength="11" type="text" />
				</view>

			</form>
		</view>
		<view class="tui-addr-save">
			<view @tap="address" class="tui-delbtn">保存</view>
		</view>
	</view>
</template>

<script>
	import mpvueCityPicker from '@/components/mpvue-citypicker/mpvueCityPicker.vue'
	export default {
		components: {
			mpvueCityPicker
		},
		data() {
			return {
				addseedata: {
					name: '',
					phone: '',
					selfFlag: '1', // 是否自提(0：否，1：是)	
				},
			}
		},
		onLoad(option) {

		},

		methods: {
			//switch开关
			onChange(e) {
				console.log(e.target.value);

			},
			address() {
				if (!this.addseedata.name) {
					uni.showToast({
						title: '请输入收货人姓名',
						icon: 'error'
					})
				} else if (!this.addseedata.phone) {
					uni.showToast({
						title: '请输入手机号',
						icon: 'error'
					})
				} else if (!(/^[1][0,1,2,3,4,5,6,7,8,9][0-9]{9}$/.test(this.addseedata.phone))) {
					uni.showToast({
						title: '手机号码格式不正确',
						icon: 'error'
					})
				} else {
					let self = this;
					uni.showLoading({
						title: '加载中'
					});
					self._postBody('user/address/add', self.addseedata, function(res) {
						uni.showToast({
							title: '新增成功',
							duration: 2000,
							icon: 'success'
						});
						uni.hideLoading();
						setTimeout(()=>{
							uni.$emit('takePerson', self.addseedata)
							uni.navigateBack({
								delta: 1
							})
						},1500)
						
					});

				}
			}
		}
	}
</script>

<style>
	page {
		background-color: #F9F9F9;
	}

	.dd-head {
		display: flex;
		justify-content: space-around;
		padding: 0rpx 54rpx;
		line-height: 84rpx;
		position: -webkit-sticky;
		position: sticky;
		top: var(--window-top);
		z-index: 99;
	}

	.dd-sitem {
		font-size: 34rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 500;
		line-height: 84rpx;
		color: #077840;
		border-bottom: 4rpx solid #077840;
		text-align: center;
	}

	.dd-item {
		font-size: 34rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 500;
		color: #333333;
		line-height: 84rpx;
		text-align: center;
	}

	.tui-addr-box {
		padding: 20rpx 30rpx 0;
		background: #FFFFFF;
	}

	.tui-line-cell {
		width: 100%;
		padding: 30rpx 0;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		background: #FFFFFF;
		border-bottom: 1rpx solid #EEEEEE;
	}

	.tui-title {
		width: 180rpx;
		height: 40rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		line-height: 40rpx;

	}

	.tui-title-city-text {
		width: 180rpx;
		height: 40rpx;
		display: block;
		line-height: 46rpx;
	}

	.tui-input {
		width: 500rpx;
	}

	.tui-input-city {
		flex: 1;
		height: 40rpx;
		font-size: 28rpx;
		padding-right: 30rpx;
	}

	.tui-phcolor {
		color: #ccc;
		font-size: 28rpx;
	}

	.tui-cell-title {
		font-size: 28rpx;
	}

	.tui-addr-label {
		margin-left: 70rpx;
	}

	.tui-label-item {
		width: 76rpx;
		height: 40rpx;
		border: 1rpx solid rgb(136, 136, 136);
		border-radius: 6rpx;
		font-size: 28rpx;
		text-align: center;
		line-height: 40rpx;
		margin-right: 20rpx;
		display: inline-block;
		transform: scale(0.9);
	}

	.tui-label-active {
		background: #135AFF;
		/* border-color:#135AFF; */
		color: #fff;
		width: 76rpx;
		height: 40rpx;
		border: 1rpx solid #135AFF;
		border-radius: 6rpx;
		font-size: 28rpx;
		text-align: center;
		line-height: 40rpx;
		margin-right: 20rpx;
		display: inline-block;
		transform: scale(0.9);
	}

	.tui-swipe-cell {
		display: flex;
		justify-content: space-between;
		background: #fff;
		padding: 20rpx 0;
		border-radius: 6rpx;
		font-size: 28rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		/* height: 98rpx; */
		/* border-bottom: 1rpx solid #EEEEEE; */
	}

	.tui-swipe-cell-left-set {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		line-height: 40rpx;

	}

	.tui-swipe-cell-left-noset {
		margin-left: 30rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 40rpx;

	}

	.tui-switch-small {
		/* transform: scale(0.8); */
		/* transform-origin: 100% center; */
		/* width: 128rpx;
		height: 60rpx; */
		/* background: #CCCCCC;
		border-radius: 30rpx; */
	}



	.tui-addr-save {
		margin-top: 30rpx;
		padding: 24rpx;
		/* margin-top: 100rpx; */
	}

	.tui-del {
		padding: 24rpx;
	}

	.tui-delbtn {
		height: 96rpx;
		background: #077840;
		border-radius: 8rpx;
		font-size: 32rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 96rpx;
		margin: 30rpx auto 0;
		text-align: center;
	}
</style>